package com.tsp_tux.demo.Dao;

import com.tsp_tux.demo.Entity.Article;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author 沈育洋
 */
public interface ArticleRepository extends JpaRepository<Article, Integer> {
    Article findByAid(int id);

    List<Article> findByTitleLike(String search);

    /**
     * 获取最新的三篇文章
     * @param uid 用户id
     * @return 文章列表
     */
    List<Article> findTop3ByUidAndStateOrderByEditTimeDesc(String uid, int state);

    List<Article> findAllBySidAndState(int sid,int state);

    @Query(value = "select mark from mark where aid=?",nativeQuery = true)
    List<Float> getArticleScoreByAid(int aid);
}
